package com.econ.powercloud.ems.controller;

import com.econ.powercloud.common.base.facade.pojo.MsgResult;
import com.econ.powercloud.common.base.facade.pojo.PageResult;
import com.econ.powercloud.console.facade.enums.EdgeCloudSwitchStatusEnum;
import com.econ.powercloud.console.facade.enums.MasterSlaveAccessMethodType;
import com.econ.powercloud.ems.common.enums.*;
import com.econ.powercloud.ems.constant.SysConstant;
import com.econ.powercloud.ems.dal.entity.EmsEnergyStation;
import com.econ.powercloud.ems.pojo.ApiDataVO;
import com.econ.powercloud.ems.pojo.DeviceDitDataVO;
import com.econ.powercloud.ems.service.biz.*;
import com.econ.powercloud.ems.service.dao.EmsEnergyStationDAO;
import com.econ.powercloud.ems.util.TimeUtil;
import com.econ.powercloud.powernode.gateway.base.utils.CurrentUserUtil;
import com.econ.powercloud.powernode.gateway.common.constants.SysConstants;
import com.econ.powercloud.powernode.gateway.common.domain.UserDTO;
import com.google.common.collect.Lists;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

@Api(tags = "数据字典")
@RestController
@RequestMapping(value = "/api/v2/dictionary")
public class DataDictionaryController extends ApiBaseController{

    @Autowired
    private DictionaryApiBizService dictionaryApiBizService;
    @Autowired
    private DeviceService deviceService;
    @Autowired
    private EnergyStationService energyStationService;
    @Autowired
    private EnergyEquipmentService energyEquipmentService;
    @Autowired
    private ElectricMeterReportService electricMeterReportService;
    @Autowired
    private ElectricBmuReportService electricBmuReportService;
    @Autowired
    private EmsAreaService emsAreaService;
    @Autowired
    private ProtectAndSoeEventService protectAndSoeEventService;
    @Autowired
    private EmsEnergyStationDAO emsEnergyStationDAO;
    @Autowired
    private DeviceSyncMsgService deviceSyncMsgService;

    @ApiOperation(value = "获取LocationUrl信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "30", dataType = "int")
    })
    @GetMapping(value = "getLocationUrl")
    public MsgResult<PageResult<List<ApiDataVO>>> getLocationUrl(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(LocationUrl.values(),null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "获取时间间隔枚举类")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getTimeIntervalType")
    public MsgResult<PageResult<List<ApiDataVO>>> getTimeIntervalType(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(TimeIntervalType.values(),null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "获取量测类型")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getMeasureType")
    public MsgResult<PageResult<List<ApiDataVO>>> getMeasureType(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(MeasureType.values(),null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "获取遥信数据值对应信息枚举")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getYxValueType")
    public MsgResult<PageResult<List<ApiDataVO>>> getYxValueType(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(YxValueType.values(),null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "获取设备状态")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getDeviceStatusType")
    public MsgResult<PageResult<List<ApiDataVO>>> getDeviceStatusType(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(DeviceStatusType.values(),null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "获取策略启用状态")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getEnabledType")
    public MsgResult<PageResult<List<ApiDataVO>>> getEnabledType(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(EnabledType.values(),null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "根据设备code获取设备的遥测数据类型")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "deviceCode", value = "设备编号",dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getAnalogTypeListByDeviceCode")
    public MsgResult<PageResult<List<ApiDataVO>>> getAnalogTypeListByDeviceId(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize,
            @RequestParam("deviceCode")String deviceCode){
        List<ApiDataVO> dataVOS = deviceService.queryAnalogTypeListByDeviceCode(deviceCode);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "根据设备code获取设备的遥信数据类型")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "deviceCode", value = "设备编号",dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getStatusTypeListByDeviceCode")
    public MsgResult<PageResult<List<ApiDataVO>>> getStatusTypeListByDeviceCode(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize,
            @RequestParam("deviceCode")String deviceCode){
        List<ApiDataVO> dataVOS = deviceService.queryStatusTypeListByDeviceCode(deviceCode);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "获取充放电状态")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getChargeType")
    public MsgResult<PageResult<List<ApiDataVO>>> getChargeDischargeType(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(ChargeDischargeType.values(), null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "模糊搜索储能站")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "searchName", value = "储能站名称",required = false,dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getEnergyStationList")
    public MsgResult<PageResult<List<ApiDataVO>>> getEnergyStationList(
            @RequestParam(value = "searchName",required = false) String searchName,
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        UserDTO user = CurrentUserUtil.get();
        PageResult<List<ApiDataVO>> result = energyStationService.getEnergyStationListByCondition(user, searchName, pageNo, pageSize);
        return pageResult(result);
    }

    @ApiOperation(value = "通过储能站ID获取其拥有的储能装置")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "stationId", value = "储能站id",dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getEquipmentListByStationId")
    public MsgResult<PageResult<List<ApiDataVO>>> getEquipmentListByStationId(
            @RequestParam(value = "stationId") String stationId,
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        PageResult<List<ApiDataVO>> result = energyEquipmentService.getEquipmentByEnergyStationId(stationId, pageNo, pageSize);
        return pageResult(result);
    }

    @ApiOperation(value = "通过储能站id,储能装置id获取电表设备")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "stationId", value = "储能站id",dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getMeterList")
    public MsgResult<PageResult<List<ApiDataVO>>> getMeterList(@RequestParam(value = "stationId") String stationId,
                                                               @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
                                                               @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        PageResult<List<ApiDataVO>> result = electricMeterReportService.getMeterList(stationId,pageNo,pageSize);
        return pageResult(result);
    }

    @ApiOperation(value = "通过储能站id,储能装置id获取BMU")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "stationId", value = "储能站id",dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "equipmentId", value = "储能装置id",dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getBMUList")
    public MsgResult<PageResult<List<ApiDataVO>>> getBMUList(@RequestParam(value = "stationId") String stationId,
                                                             @RequestParam(value = "equipmentId")String equipmentId,
                                                             @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
                                                             @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        PageResult<List<ApiDataVO>> result = electricBmuReportService.getBMUList(stationId,equipmentId,pageNo,pageSize);
        return pageResult(result);
    }

    @ApiOperation(value = "获取所有遥调遥控数据对应的位置信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getYtYkLocation")
    public MsgResult<PageResult<List<ApiDataVO>>> getYtYkLocation(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(YkYtLocationType.values(),null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "获取计算点号对应的位置信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "30", dataType = "int")
    })
    @GetMapping(value = "getCalLocationUrl")
    public MsgResult<PageResult<List<ApiDataVO>>> getCalLocationUrl(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(CalLocationType.values(),null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "获取电压等级")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getVoltageLevel")
    public MsgResult<PageResult<List<ApiDataVO>>> getVoltageLevel(@RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
                                                                  @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(VoltageLevel.values(), Lists.newArrayList(VoltageLevel.ALL));
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "获取省集合")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "search", value = "省名称",required = false,dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getProvinceList")
    public MsgResult<PageResult<List<ApiDataVO>>> getProvinceList(@RequestParam(value = "search",required = false)String search,
                                                                  @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
                                                                  @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        PageResult<List<ApiDataVO>> dataVOS = emsAreaService.getProvinceList(search,pageNo, pageSize);
        return pageResult(dataVOS);
    }

    @ApiOperation(value = "获取省下的市集合")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "province", value = "省id",required = false,dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getCityList")
    public MsgResult<PageResult<List<ApiDataVO>>> getCityList(@RequestParam(value = "province",required = false)Integer province,
                                                                  @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
                                                                  @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        PageResult<List<ApiDataVO>> dataVOS = emsAreaService.getCityPage(province,pageNo, pageSize);
        return pageResult(dataVOS);
    }

    @ApiOperation(value = "获取设备类型")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getDeviceType")
    public MsgResult<PageResult<List<ApiDataVO>>> getDeviceType(@RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
                                                                @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(DeviceType.values(), null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "根据设备类型,储能站,储能装置获取设备列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "stationId", value = "储能站id",dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "equipmentId", value = "储能装置id",required = false,dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "deviceType", value = "设备类型",dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getDeviceListByCondition")
    public MsgResult<PageResult<List<ApiDataVO>>> getDeviceListByCondition(@RequestParam(value = "stationId") String stationId,
                                                                           @RequestParam(value = "equipmentId",required = false) String equipmentId,
                                                                           @RequestParam(value = "deviceType",required = false) Integer deviceType,
                                                                           @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
                                                                           @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        PageResult<List<ApiDataVO>> result = deviceService.getPageByStationIdAndEquipmentIdAndDeviceType(stationId, equipmentId, deviceType, pageNo, pageSize);
        return pageResult(result);
    }

    @ApiOperation(value = "根据子设备类型与父设备code查找子设备")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "deviceCode", value = "父设备id",dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "deviceType", value = "设备类型",dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getChildDeviceByCondition")
    public MsgResult<PageResult<List<ApiDataVO>>> getChildDeviceByCondition(@RequestParam(value = "deviceCode") String deviceCode,
                                                                            @RequestParam(value = "deviceType") Integer deviceType,
                                                                            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
                                                                            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        PageResult<List<ApiDataVO>> result = deviceService.getPageChildDeviceByCondition(deviceCode, deviceType, pageNo, pageSize);
        return pageResult(result);
    }

    @ApiOperation(value = "获取公司类型")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getCompanyType")
    public MsgResult<PageResult<List<ApiDataVO>>> getCompanyType(@RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
                                                                 @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(CompanyType.values(), null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "获取簇的故障告警状态")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getClusterStatus")
    public MsgResult<PageResult<List<ApiDataVO>>> getClusterStatus(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(AlarmOrFaultState.values(),null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "获取PCU或PCS的状态")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getPCSOrPCUStatus")
    public MsgResult<PageResult<List<ApiDataVO>>> getPCSOrPCUStatus(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(PcsOrPcuRunStatus.values(),null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "获取组合类型")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getCombinationType")
    public MsgResult<PageResult<List<ApiDataVO>>> getCombinationType(@RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
                                                                 @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(CombinationType.values(), null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "获取故障来源")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getEventSourceType")
    public MsgResult<PageResult<List<ApiDataVO>>> getEventResourceType(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(EventSourceType.values(), null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "获取故障处理状态")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getEventDealStatusType")
    public MsgResult<PageResult<List<ApiDataVO>>> getEventDealStatus(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(EventDealStatusType.values(), null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "获取故障设备")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "search", value = "设备名称", dataType = "string",required = false),
            @ApiImplicitParam(paramType = "query", name = "energyStationId", value = "储能站id", dataType = "string",required = false),
            @ApiImplicitParam(paramType = "query", name = "energyEquipmentId", value = "储能装置id", dataType = "string",required = false),
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getFaultDevice")
    public MsgResult<PageResult<List<ApiDataVO>>> getFaultDevice(@RequestParam(required = false) String search,
                                                                 @RequestParam(required = false) String energyStationId,
                                                                 @RequestParam(required = false) String energyEquipmentId,
                                                                 @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
                                                                 @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize) {
        PageResult<List<ApiDataVO>> result = deviceService.getDeviceListBySearch(search, energyStationId, energyEquipmentId, pageNo, pageSize);
        return pageResult(result);
    }

    @ApiOperation(value = "获取储能站类型")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getStationType")
    public MsgResult<PageResult<List<ApiDataVO>>> getStationType(@RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
                                                                     @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(StationType.values(), null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation("获取操作端")
    @GetMapping("getEdgeSendSourceMsgType")
    public MsgResult<List<ApiDataVO>> getEdgeSendSourceMsgType() {
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(EdgeSendSourceMsgType.values(),
                Lists.newArrayList(EdgeSendSourceMsgType.FROM_IOT_CLOUD,EdgeSendSourceMsgType.FROM_MQTT_BROKER,EdgeSendSourceMsgType.FROM_PARTY3));
        return this.successHandler(dataVOS);
    }

    @ApiOperation("获取操作类型")
    @GetMapping("getDeviceOperationMsgType")
    public MsgResult<List<ApiDataVO>> getDeviceOperationMsgType() {
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(DeviceOperationMsgType.values(), null);
        return this.successHandler(dataVOS);
    }

    @ApiOperation("获取相别")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "deviceCode", value = "设备编号", dataType = "String")
    })
    @GetMapping("getProtectEventPhaseType")
    public MsgResult<List<ApiDataVO>> getProtectEventPhaseType(@RequestParam String deviceCode) {
        return successHandler(protectAndSoeEventService.getConfigByCondition(deviceCode,ProtectAndSoeFiledEnum.PHASE));
    }

    @ApiOperation("获取动作类别")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "deviceCode", value = "设备编号", dataType = "String")
    })
    @GetMapping("getProtectEventActionType")
    public MsgResult<List<ApiDataVO>> getProtectEventActionType(@RequestParam String deviceCode) {
        return successHandler(protectAndSoeEventService.getConfigByCondition(deviceCode,ProtectAndSoeFiledEnum.ATYPE));
    }

    /**
     * 云端设置状态
     */
    @ApiOperation(value = "云端设置状态")
    @GetMapping(value = "cloudControlStatus")
    public MsgResult<List<ApiDataVO>> cloudControlStatus() {
        EdgeCloudSwitchStatusEnum[] values = EdgeCloudSwitchStatusEnum.values();
        List<ApiDataVO> dataVOS = Lists.newArrayList();
        for (EdgeCloudSwitchStatusEnum typeEnum:values) {
            dataVOS.add(ApiDataVO.builder().code(typeEnum.getCode()).name(typeEnum.getDesc()).build());
        }
        return this.successHandler(dataVOS);
    }

    /**
     * 发送状态
     */
    @ApiOperation(value = "发送状态")
    @GetMapping(value = "iotMsgStatus")
    public MsgResult<List<ApiDataVO>> iotMsgStatus() {
        List<ApiDataVO> dataVOList = dictionaryApiBizService.getApiDataVOList(IotMsgStatus.values(),null);
        return this.successHandler(dataVOList);
    }

    @ApiOperation(value = "获取基本电费类型")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getBasicElectricity")
    public MsgResult<PageResult<List<ApiDataVO>>> getBasicElectricity(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(BasicElectricity.values(), null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "获取电价类型")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getPriceType")
    public MsgResult<PageResult<List<ApiDataVO>>> getPriceType(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(PriceType.values(), null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "获取计费类型")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getIncomeCalculationType")
    public MsgResult<PageResult<List<ApiDataVO>>> getIncomeCalculationType(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(IncomeCalculationType.values(), null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "获取电价模型-特殊情况的条件")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getCaseType")
    public MsgResult<PageResult<List<ApiDataVO>>> getCaseType(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(CaseType.values(), null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "获取电价模型-特殊情况的判断条件")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getConditionType")
    public MsgResult<PageResult<List<ApiDataVO>>> getConditionType(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(ConditionType.values(), null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "获取未设置位置的电池簇")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "deviceCode", value = "设备编号(集装箱/相)", dataType = "String")
    })
    @GetMapping("getUnSeatCluster")
    public MsgResult<List<ApiDataVO>> getUnSeatCluster(@RequestParam("deviceCode")String deviceCode){
        return successHandler(deviceService.getUnSeatCluster(deviceCode));
    }

    @ApiOperation(value = "获取点号类型")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getDitTypeEnum")
    public MsgResult<PageResult<List<ApiDataVO>>> getDitTypeEnum(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(DitTypeEnum.values(), null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "获取模块位置枚举")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getModulePositionEnum")
    public MsgResult<PageResult<List<ApiDataVO>>> getModulePositionEnum(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(ModulePositionEnum.values(), null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @GetMapping(value = "getDeviceCodeByDeviceName")
    @ApiOperation(value="根据设备名称获取设备信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "search", value = "设备名称", required = false, dataType = "String"),
            @ApiImplicitParam(name = "pageNo", value = "页", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "行", required = true, dataType = "Integer")
    })
    public MsgResult<PageResult<List<ApiDataVO>>> getDeviceCodeByDeviceName(@RequestParam(value = "search",required = false)String search,
                                                                            @RequestParam("pageNo")Integer pageNo,
                                                                            @RequestParam("pageSize")Integer pageSize){
        return successHandler(deviceService.getDeviceCodeByDeviceName(search, pageNo, pageSize));
    }

    @GetMapping(value = "getDeviceYcDit")
    @ApiOperation(value="获取设备的遥测点号数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "deviceCode", value = "设备编码", required = true, dataType = "String"),
            @ApiImplicitParam(name = "search", value = "点号名称或点号标识", dataType = "String"),
            @ApiImplicitParam(name = "pageNo", value = "页", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "行", required = true, dataType = "Integer")
    })
    public MsgResult<PageResult<List<ApiDataVO>>> getDeviceDitList(@RequestParam("deviceCode")String deviceCode,
                                                                   @RequestParam(value = "search",required = false)String search,
                                                                   @RequestParam("pageNo")Integer pageNo,
                                                                   @RequestParam("pageSize")Integer pageSize){
        PageResult<List<DeviceDitDataVO>> result = deviceService.getDeviceYcDit(deviceCode, null,search, pageNo, pageSize);
        return successHandler(PageResult.<List<ApiDataVO>>builder()
                .data(CollectionUtils.isEmpty(result.getData())? Collections.emptyList()
                        :result.getData().stream().map(d -> new ApiDataVO(d.getDit(), d.getDitName())).collect(Collectors.toList()))
                .pageNo((int)result.getPageNo()).totalCount((int)result.getTotalCount()).build());
    }

    @GetMapping(value = "getDeviceYxDit")
    @ApiOperation(value="获取设备的遥信点号数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "deviceCode", value = "设备编码", required = true, dataType = "String"),
            @ApiImplicitParam(name = "search", value = "点号名称或点号标识", dataType = "String"),
            @ApiImplicitParam(name = "pageNo", value = "页", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "行", required = true, dataType = "Integer")
    })
    public MsgResult<PageResult<List<ApiDataVO>>> getDeviceYxDit(@RequestParam("deviceCode")String deviceCode,
                                                                 @RequestParam(value = "search",required = false)String search,
                                                                 @RequestParam("pageNo")Integer pageNo,
                                                                 @RequestParam("pageSize")Integer pageSize){
        PageResult<List<DeviceDitDataVO>> result = deviceService.getDeviceYxDit(deviceCode, null,search, pageNo, pageSize);
        return successHandler(PageResult.<List<ApiDataVO>>builder()
                .data(CollectionUtils.isEmpty(result.getData())? Collections.emptyList()
                        :result.getData().stream().map(d -> new ApiDataVO(d.getDit(), d.getDitName())).collect(Collectors.toList()))
                .pageNo((int)result.getPageNo()).totalCount((int)result.getTotalCount()).build());
    }

    @GetMapping(value = "getDeviceYtDit")
    @ApiOperation(value="获取设备的遥调点号数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "deviceCode", value = "设备编码", required = true, dataType = "String"),
            @ApiImplicitParam(name = "search", value = "点号名称或点号标识", dataType = "String"),
            @ApiImplicitParam(name = "pageNo", value = "页", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "行", required = true, dataType = "Integer")
    })
    public MsgResult<PageResult<List<ApiDataVO>>> getDeviceYtDit(@RequestParam("deviceCode")String deviceCode,
                                                                 @RequestParam(value = "search",required = false)String search,
                                                                 @RequestParam("pageNo")Integer pageNo,
                                                                 @RequestParam("pageSize")Integer pageSize){
        PageResult<List<DeviceDitDataVO>> result = deviceService.getDeviceYtDit(deviceCode, search, pageNo, pageSize);
        return successHandler(PageResult.<List<ApiDataVO>>builder()
                .data(CollectionUtils.isEmpty(result.getData())? Collections.emptyList()
                        :result.getData().stream().map(d -> new ApiDataVO(d.getDit(), d.getDitName())).collect(Collectors.toList()))
                .pageNo((int)result.getPageNo()).totalCount((int)result.getTotalCount()).build());
    }

    @GetMapping(value = "getDeviceYkDit")
    @ApiOperation(value="获取设备的遥控点号数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "deviceCode", value = "设备编码", required = true, dataType = "String"),
            @ApiImplicitParam(name = "search", value = "点号名称或点号标识", dataType = "String"),
            @ApiImplicitParam(name = "pageNo", value = "页", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "行", required = true, dataType = "Integer")
    })
    public MsgResult<PageResult<List<ApiDataVO>>> getDeviceYkDit(@RequestParam("deviceCode")String deviceCode,
                                                                 @RequestParam(value = "search",required = false)String search,
                                                                 @RequestParam("pageNo")Integer pageNo,
                                                                 @RequestParam("pageSize")Integer pageSize){
        PageResult<List<DeviceDitDataVO>> result = deviceService.getDeviceYkDit(deviceCode, search, pageNo, pageSize);
        return successHandler(PageResult.<List<ApiDataVO>>builder()
                .data(CollectionUtils.isEmpty(result.getData())? Collections.emptyList()
                        :result.getData().stream().map(d -> new ApiDataVO(d.getDit(), d.getDitName())).collect(Collectors.toList()))
                .pageNo((int)result.getPageNo()).totalCount((int)result.getTotalCount()).build());
    }

    @GetMapping(value = "getDeviceCalYcDit")
    @ApiOperation(value="获取设备的计算遥测点号数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "deviceCode", value = "设备编码", required = true, dataType = "String"),
            @ApiImplicitParam(name = "search", value = "点号名称或点号标识", dataType = "String"),
            @ApiImplicitParam(name = "pageNo", value = "页", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "行", required = true, dataType = "Integer")
    })
    public MsgResult<PageResult<List<ApiDataVO>>> getDeviceCalYcDit(@RequestParam("deviceCode")String deviceCode,
                                                                    @RequestParam(value = "search",required = false)String search,
                                                                    @RequestParam("pageNo")Integer pageNo,
                                                                    @RequestParam("pageSize")Integer pageSize){
        PageResult<List<DeviceDitDataVO>> result = deviceService.getDeviceCalYcDit(deviceCode, search, pageNo, pageSize);
        return successHandler(PageResult.<List<ApiDataVO>>builder()
                .data(CollectionUtils.isEmpty(result.getData())? Collections.emptyList()
                        :result.getData().stream().map(d -> new ApiDataVO(d.getDit(), d.getDitName())).collect(Collectors.toList()))
                .pageNo((int)result.getPageNo()).totalCount((int)result.getTotalCount()).build());
    }

    @GetMapping(value = "getDeviceCalYxDit")
    @ApiOperation(value="获取设备的计算遥信点号数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "deviceCode", value = "设备编码", required = true, dataType = "String"),
            @ApiImplicitParam(name = "search", value = "点号名称或点号标识", dataType = "String"),
            @ApiImplicitParam(name = "pageNo", value = "页", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "行", required = true, dataType = "Integer")
    })
    public MsgResult<PageResult<List<ApiDataVO>>> getDeviceCalYxDit(@RequestParam("deviceCode")String deviceCode,
                                                                    @RequestParam(value = "search",required = false)String search,
                                                                    @RequestParam("pageNo")Integer pageNo,
                                                                    @RequestParam("pageSize")Integer pageSize){
        PageResult<List<DeviceDitDataVO>> result = deviceService.getDeviceCalYxDit(deviceCode, search, pageNo, pageSize);
        return successHandler(PageResult.<List<ApiDataVO>>builder()
                .data(CollectionUtils.isEmpty(result.getData())? Collections.emptyList()
                        :result.getData().stream().map(d -> new ApiDataVO(d.getDit(), d.getDitName())).collect(Collectors.toList()))
                .pageNo((int)result.getPageNo()).totalCount((int)result.getTotalCount()).build());
    }

    @GetMapping(value = "getDeviceJhDit")
    @ApiOperation(value="获取设备的计划点号数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "deviceCode", value = "设备编码", required = true, dataType = "String"),
            @ApiImplicitParam(name = "search", value = "点号名称或点号标识", dataType = "String"),
            @ApiImplicitParam(name = "pageNo", value = "页", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "行", required = true, dataType = "Integer")
    })
    public MsgResult<PageResult<List<ApiDataVO>>> getDeviceJhDit(@RequestParam("deviceCode")String deviceCode,
                                                                    @RequestParam(value = "search",required = false)String search,
                                                                    @RequestParam("pageNo")Integer pageNo,
                                                                    @RequestParam("pageSize")Integer pageSize){
        PageResult<List<DeviceDitDataVO>> result = deviceService.getDeviceJhDit(deviceCode, search, pageNo, pageSize);
        return successHandler(PageResult.<List<ApiDataVO>>builder()
                .data(CollectionUtils.isEmpty(result.getData())? Collections.emptyList()
                        :result.getData().stream().map(d -> new ApiDataVO(d.getDit(), d.getDitName())).collect(Collectors.toList()))
                .pageNo((int)result.getPageNo()).totalCount((int)result.getTotalCount()).build());
    }

    @GetMapping(value = "getMinHisStartTime")
    @ApiOperation(value = "获取查询历史数据的最小开始时间")
    public MsgResult<Long> getMinHisStartTime(){
        //获取储能站投运时间
        List<EmsEnergyStation> stationList = emsEnergyStationDAO.list();
        if(CollectionUtils.isEmpty(stationList)){
            return successHandler(System.currentTimeMillis());
        }
        Long commissionTime = stationList.get(0).getCommissioningDate();
        //最多只能查询三年前的时间
        Long searchTime = TimeUtil.getOtherYearWithYear(-3);
        return successHandler(commissionTime > searchTime? commissionTime : searchTime);
    }

    @GetMapping(value = "getMasterSlaveAccessMethod")
    @ApiOperation(value="获取主备切换访问方式")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    public MsgResult<PageResult<List<ApiDataVO>>> getMasterSlaveAccessMethod(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = Lists.newArrayList();
        Arrays.asList(MasterSlaveAccessMethodType.values()).forEach(apiType -> {
            dataVOS.add(ApiDataVO.builder().code(apiType.getCode()).name(apiType.getDesc()).build());
        });
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @ApiOperation(value = "获取模块位置枚举")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    @GetMapping(value = "getWarnSortFieldType")
    public MsgResult<PageResult<List<ApiDataVO>>> getWarnSortFieldType(
            @RequestParam(value = "pageNo", defaultValue = SysConstant.DEFAULT_PAGENO) Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = SysConstant.DEFAULT_PAGESIZE) Integer pageSize){
        List<ApiDataVO> dataVOS = dictionaryApiBizService.getApiDataVOList(WarnSortFieldType.values(), null);
        return pageResult(PageResult.<List<ApiDataVO>>builder().data(dataVOS).pageNo(pageNo).totalCount(dataVOS.size()).build());
    }

    @GetMapping("clientIp")
    @ApiOperation("获取操作记录下的客户端ip")
    public MsgResult<List<String>> getClientIp(){
        return this.successHandler(deviceSyncMsgService.getClientIpList());
    }

}

